package com.ldl.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ldl.filter.MyFilter;

/**
 * @author Administrator
 * Author : L.D.L
 * E-mail : 1419485293@qq.com
 * Date : 2020年8月7日下午7:18:43
 */
@WebListener
public class MyListener implements ServletContextListener,HttpSessionListener,ServletRequestListener{

	private static Logger log1 = LoggerFactory.getLogger(MyListener.class) ;
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		ServletContext application = sce.getServletContext();
//		System.out.println("上下文对象创建了"+application);
//		log1.debug("上下文对象创建了:{}",application);
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		ServletContext application = sce.getServletContext();
//		System.out.println("上下文对象销毁了了"+application);
//		log1.debug("上下文对象销毁了:{}",application);
	}
	
	@Override
	public void requestInitialized(ServletRequestEvent sre) {
		//请求的创建
		HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
//		System.out.println("创建了请求："+request);
//		log1.debug("创建了请求:{}",request);
		
	}

	@Override
	public void requestDestroyed(ServletRequestEvent sre) {
		//请求的销毁
		HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
//		System.out.println("销毁了请求："+request);
//		log1.debug("销毁了请求:{}",request);
	}

	@Override
	public void sessionCreated(HttpSessionEvent se) {
		//会话创建
		HttpSession session = se.getSession();
//		System.out.println("创建了会话："+session);
//		log1.debug("创建了会话:{}",session);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		//会话销毁
		HttpSession session = se.getSession();
//		System.out.println("销毁了会话："+session);
//		log1.debug("销毁了会话:{}",session);
	}

}
